package org.mili.ticketeer.dto;

import org.mili.application.dto.Archivable;
import org.mili.application.dto.Attributeable;
import org.mili.application.dto.Field;

import java.util.HashMap;
import java.util.Map;

public class ContactAction extends Attributeable implements Archivable {

    public static enum Fields implements Field {
        ACTION,
        CONTACT;
    }

    public static enum UniqueFields implements Field {
        ACTION,
        CONTACT;
    }

    public static final String TABLE = "contact_action";

    private int action;
    private int contact;

    public Map<Field, Object> valueMap() {
        Map<Field, Object> map = new HashMap<>();
        map.put(Fields.ACTION, getAction());
        map.put(Fields.CONTACT, getContact());
        return map;
    }

    public Map<Field, Object> valueMapWithoutId() {
        return valueMap();
    }

    @Override
    public Map<Field, Object> getUniqueFields() {
        return valueMap();
    }

    public int getAction() {
        return action;
    }

    public void setAction(int action) {
        this.action = action;
    }

    public int getContact() {
        return contact;
    }

    public void setContact(int contact) {
        this.contact = contact;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ContactAction that = (ContactAction) o;

        if (action != that.action) return false;
        if (contact != that.contact) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = action;
        result = 31 * result + contact;
        return result;
    }

    @Override
    public String toString() {
        return "ContactAction{" +
                "action=" + action +
                ", contact=" + contact +
                '}';
    }
}
